home *** CD-ROM | disk | FTP | other *** search
- // DESCRIPTION:
- // AI script for Menero's Thug.
- //
- // AUTHOR:
- // Boon
- // BEGUN:
- // 28th October 1998
-
- //Menero's Thug is an enemy, meaning he will attack hardcorps guys
- local.self enemy
- //Tell him to ignore everything and then, below, change
- //particular states so he won't ignore them
- local.self ignoreall
-
- //
- // Define the default states for Mr Thug
- // Note that these are often changed in level scripts anyhow
- //
- local.self definestate idle global/baseai.scr::idle
- local.self definestate twitch global/baseai.scr::twitch
- local.self definestate pain global/baseai.scr::pain
- local.self definestate opendoor global/baseai.scr::opendoor
- local.self definestate activate global/baseai.scr::attackentity
- local.self definestate use global/baseai.scr::attackentity
- local.self definestate jump global/baseai.scr::jump
-
- local.self definestate sightenemy sightenemy
- //local.self definestate sightenemy global/baseai.scr::sightenemy
- //Manero's Thugs have a different attacking behaviour from standard monsters
- local.self definestate duckandcover duckandcover
- local.self definestate standground global/baseai.scr::standground
- local.self definestate blitzattack global/baseai.scr::blitz_attack
- local.self definestate meleeattack global/baseai.scr::meleeattack
-
- local.self definestate default_sightenemy global/baseai.scr::sightenemy
- //local.self definestate simpleattack duckandcover
- local.self definestate simpleattack global/baseai.scr::attackentity
- //local.self definestate weaponsound maybe_protect_head
- local.self definestate weaponsound global/baseai.scr::urgent_investigate
- local.self definestate movementsound global/baseai.scr::investigate
- local.self definestate painsound global/baseai.scr::investigate
- local.self definestate deathsound investigate
- // This makes them duck if you whizz a bullet past their ear (well, it's
- // not that good, but occasionally it gives that impression)
- local.self definestate breakingsound protect_head
- //local.self definestate breakingsound global/baseai.scr::urgent_investigate
- local.self definestate doorsound global/baseai.scr::investigate
- local.self definestate mutantsound global/baseai.scr::urgent_investigate
- local.self definestate voicesound global/baseai.scr::investigate
- local.self definestate radiosound global/baseai.scr::investigate
-
- //goto global/baseai.scr::init
- goto init
-
- end
-
-
- //************************************************************
- //
- // protect_head:
- //
- // When the Thug hears a gunshot, his first instinct is to
- // duck. He then looks around a bit, and then goes and has
- // a look.
- //
- //************************************************************
-
- protect_head:
-
- // increase his paranoia
- local.paranoia += 6
-
- //local.randchoice randomint 3
- //local.randchoice ifequal 0 goto global/baseai.scr::urgent_investigate
- local.self anim crouch
- waitFor local.self
- local.self anim crouch_idle
-
- local.self lookAt local.other
- wait 1
-
- // turn a bit
- parm.yaw = local.yaw
- parm.yaw += 140
- local.self turnto parm.yaw
- local.randchoice randomint 2
- local.randchoice /= 2
- wait local.randchoice
-
- // turn a bit more
- parm.yaw = local.yaw
- parm.yaw += 50
- local.self turnto parm.yaw
- local.randchoice randomint 3
- local.randchoice /= 2
- wait local.randchoice
-
- local.randchoice randomint 15
- local.randchoice ifequal 1 goto protecthead_step
- goto protecthead_continue
-
- protecthead_step:
-
- local.self anim "crouch_walk"
- waitFor local.self
-
- protecthead_continue:
-
- // turn a bit more
- parm.yaw = local.yaw
- parm.yaw += 20
- local.self turnto parm.yaw
- //wait 2
-
- //Stay ducked for up to 2 more seconds
- local.randchoice randomint 2
- local.randchoice ifequal 0 local.randchoice += 1
- wait local.randchoice
-
- local.self anim "crouch_return"
- waitFor local.self
- goto investigate
-
- //************************************************************
- // Maybe_protect_head
- //************************************************************
-
- maybe_protect_head:
-
- local.randchoice randomint 2
- local.randchoice ifequal 1 goto global/baseai.scr::urgent_investigate
-
- // Decrease his paranoia because protect_head will increase it again
- local.paranoia -= 3
-
- goto protect_head
-
- //************************************************************
- //
- // investigate:
- // Actor walks to location and fights enemies along the way.
- // If really paranoid, runs to location.
- //
- // My version just alters the behaviour a little, makes them
- // duck a bit, etc
- //
- //************************************************************
-
- investigate:
-
- // see if we are in stand ground mode
- // if we are we don't want to investigate
- local.attackmode ifequal 1 goto dont_investigate
-
- // increase his paranoia
- local.paranoia += 2
-
- // Just look at the cause
- local.paranoia ifgreater 9 goto skiplook
- local.self anim idle
- local.self lookAt local.other
- wait 0.6
-
- skiplook:
-
- // if paranoid, go check it out
- local.paranoia ifgreater 6 goto investigate_walkover
-
- wait 5
-
- // go back to what we were doing
- end
-
- investigate_walkover:
-
- local.self clearstate
-
- // normally, just walk over
- parm.anim string "walk"
-
- // if really paranoid run over there
- local.paranoia ifgreater 8 parm.anim string "run"
-
- local.self behavior Investigate parm.anim local.location
- waitFor local.self
-
- //if really really paranoid, crouch while looking
- local.paranoia ifless 11 goto investigate_stand
-
- investigate_duck:
-
- local.self anim crouch
- waitFor local.self
- local.self anim crouch_idle
-
- // turn a bit
- parm.yaw = local.yaw
- local.randchoice randomint 8
- local.randchoice *= 10
- local.randchoice += 30
- parm.yaw += local.randchoice
- local.self turnto parm.yaw
-
- // Maybe shuffle forward a bit
- local.randchoice randomint 20
- local.randchoice ifequal 1 goto investigate_step1
- goto investigate_continue1
-
- investigate_step1:
-
- // Don't step if we are really paranoid since we'll be here again and
- // we don't want to step too many times.
- local.paranoia ifgreater 14 goto investigate_continue1
- local.self anim "crouch_walk"
- waitFor local.self
-
- investigate_continue1:
-
- // Turn a bit more
- parm.yaw = local.yaw
- parm.yaw -= 50
- local.self turnto parm.yaw
- local.randchoice randomint 4
- local.randchoice /= 2
- wait local.randchoice
-
- // Perhaps shuffle again
- local.randchoice randomint 15
- local.randchoice ifequal 1 goto investigate_step2
- goto investigate_continue2
-
- investigate_step2:
-
- // Don't step if we are really paranoid since we'll be here again and
- // we don't want to step too many times.
- local.paranoia ifgreater 14 goto investigate_continue1
- local.self anim "crouch_walk"
- waitFor local.self
-
- investigate_continue2:
-
- // turn a bit more
- parm.yaw = local.yaw
- parm.yaw += 50
- local.self turnto parm.yaw
-
- //Stay ducked for up to 3 more seconds
- local.randchoice randomint 2
- local.randchoice += 1
- wait local.randchoice
-
- // OK, so we've looked around, and haven't seen anyone
- local.paranoia -= 5
- local.paranoia ifgreater 9 goto investigate_duck
- local.self anim "crouch_return"
- waitFor local.self
- local.paranoia ifless 4 goto dont_investigate
-
- investigate_stand:
-
- // stand around for a bit
- local.self anim idle
- local.self lookAt local.other
- wait 2
-
- // turn a bit
- parm.yaw = local.yaw
- parm.yaw += 70
- local.randchoice randomint 2
- local.randchoice /= 2
- wait local.randchoice
-
- // turn a bit
- parm.yaw = local.yaw
- parm.yaw += 50
- local.randchoice randomint 3
- local.randchoice /= 3
- wait local.randchoice
-
- // turn a bit more
- parm.yaw = local.yaw
- parm.yaw += 110
- local.self turnto parm.yaw
- local.randchoice randomint 5
- local.randchoice /= 2
- wait local.randchoice
-
- // Hmmm, didn't see anything. Must have been nothing.
- // Go back to where we started
- local.self walkto local.startpos
- waitFor local.self
-
- local.self state idle
- end
-
- dont_investigate:
- //
- // since we are in stand ground,
- // Just look at the cause
- //
- local.self anim idle
- local.self lookAt local.other
- wait 0.4
- end
-
-
- //***************************************************************
- //
- // duckandcover:
- // In this version of duckandcover, he tries to plug his enemy
- // without coming out from behind his cover.
- //
- // This is based off SiN's duckandcover code.
- //
- //****************************************************************
-
- duckandcover:
-
- local.self ifcanmeleeattack goto duckandcover_melee
-
- // find our enemy
- // (Boon) FindEnemy moves around the pathnodes until it
- // determines that it can shoot the enemy, or gives up.
- local.self behavior FindEnemy "run"
- waitFor local.self
-
- //
- // in case we couldn't get to the enemy at all
- //
- local.enemy ifstrequal "" goto duckandcover_end
-
- //
- // can we get a bead on him
- //
- local.self ifcanshoot goto duckandcover_continue
-
- //
- // otherwise continue searching
- //
- goto duckandcover
-
-
- duckandcover_continue:
- //
- //Since the Thug should be good at shooting from behind cover, he is
- //more likely to run and hide.
- //
- local.randchoice randomint 2
- //local.randchoice ifequal 0 goto duckandcover_hide
- local.randchoice ifequal 0 local.self behavior FindCover "run"
-
- local.self ifcanstrafeattack goto duckandcover_strafeattack
-
- //
- // take 5 shots
- // (Boon) What's this about 5? I don't see where 5 came from
- // 5 is actually a typical value for local.shots_per_attack I think
- //
- local.shotsleft = 1
-
-
- duckandcover_shoot:
- local.self behavior AimAndShoot local.shots_per_attack
- waitFor local.self
- local.shotsleft -= 1
-
- local.enemy ifstrequal "" goto duckandcover_end
- //
- // did he lose his weapon
- //
- local.has_weapon ifequal 0 goto duckandcover_evaluate
-
- local.shotsleft ifgreater 0 goto duckandcover_shoot
-
-
- //***********************
- // Duckandcover_hide
- //***********************
-
- duckandcover_hide:
- //
- // run and hide
- //
- //local.self behavior FindCover "run"
- //waitFor local.self
- local.enemy ifstrnotequal "" local.self lookat local.enemy
-
- // Generate a time between 1 and 3 seconds to stay down for
- local.hidetime = game.time
- local.hidetime += 2
- //local.randchoice randomint 2
- //local.hidetime += local.randchoice
-
- //
- // Now duck, and call the code that makes him shoot while ducked
- //
- local.self anim crouch
- //local.enemy ifstrnotequal "" local.self lookat local.enemy
- waitfor local.self
- local.self anim crouch_idle
-
- duckandcover_hide_shoot:
-
- // DuckAttack is causing some problems:
- // If we go through once, and then again immediately after,
- // or something like that, it seems to lock the thug in position,
- // which is bad.
- local.self behavior DuckAttack
- waitfor local.self
- local.self behavior Lean_AimandShoot local.shots_per_attack "crouch_"
- waitfor local.self
- wait 0.5
-
- duckandcover_wait:
- //
- // Get up if we're seen, otherwise, usually stay down and keep killing (heh)
- //
- local.self ifenemyvisible goto duckandcover_unhide
- //local.self ifenemyvisible goto duckandcover_done
-
- local.randchoice randomint 10
- local.randchoice ifequal 0 goto duckandcover_done
- goto duckandcover_hide_shoot
-
- duckandcover_done:
- game.time ifless local.hidetime goto duckandcover_wait
-
- duckandcover_unhide:
- local.self anim "crouch_return"
- waitfor local.self
- goto duckandcover
-
-
- //******************
- // Strafe attack
- //******************
-
- duckandcover_strafeattack:
-
- // try to fire right away
- local.self behavior AimAndShoot local.shots_per_attack
- waitFor local.self
- local.enemy ifstrequal "" goto duckandcover_end
- // did he lose his weapon
- local.has_weapon ifequal 0 goto duckandcover_evaluate
-
- local.oldpos vector local.origin
- local.self reservenode local.oldpos 10
- local.self behavior StrafeAttack
- waitFor local.self
-
- local.self behavior AimAndShoot local.shots_per_attack
- waitFor local.self
- local.enemy ifstrequal "" goto duckandcover_end
- // did he lose his weapon
- local.has_weapon ifequal 0 goto duckandcover_evaluate
-
- local.self ifcanhideat local.oldpos goto duckandcover_strafehide
- local.self releasenode local.oldpos
-
- local.self behavior FindCover "run"
- waitFor local.self
- goto duckandcover_hide
- //goto duckandcover
-
- duckandcover_strafehide:
- // This strafes back to somewhere where he could hide
-
- local.self behavior StrafeTo local.oldpos
- waitFor local.self
-
- goto duckandcover_hide
- //local.self usecover
- //local.hidetime = game.time
- //local.hidetime += 2
- //goto duckandcover_wait
-
- duckandcover_end:
- end
-
- duckandcover_melee:
-
- local.self behavior AimAndMelee local.shots_per_attack
- waitFor local.self
- goto duckandcover
- end
-
- //************************************************************
- //
- // sightenemy:
- // Same as the regular sightenemy, except that he
- // doesn't ignore breaking sounds any more
- //
- //************************************************************
-
- sightenemy:
-
- local.self clearstate
-
- // crank up his paranoia level
- local.paranoia += 20
-
- local.self respondtoall
- local.self ignore activate use
- local.self ignoresounds
- //local.self definestate breakingsound maybe_protect_head
-
- duckandcover_evaluate:
- //
- // see if we lost our weapon or never had one
- //
- local.has_weapon ifequal 0 local.self state meleeattack
- local.attackmode ifequal 0 local.self state duckandcover
- local.attackmode ifequal 1 local.self state standground
- local.attackmode ifequal 2 local.self state blitzattack
- local.self state idle
- end
-
-
- //************************************************************
- //
- // init:
- // Initialize variables and "hidden" states and goto idle state.
- //
- // I had to move this here so it would call the proper idle...
- //
- //************************************************************
-
- init:
-
- local.paranoia = 0
- local.self state idle
-
- end
-
- //************************************************************
- //
- // idle:
- // Alert, but standing around waiting for action.
- // Altered to allow for smokos.
- //
- // Smoko stuff doesn't work, plus it would be setting a bad
- // example for the kids, plus the tech_guards don't have smoko
- // animations anyhow, so I've removed it.
- //
- //************************************************************
-
- idle:
-
- local.self clearstate
- local.self respondtoall
-
- idle_loop:
-
- local.self idle "idle"
- waitFor local.self
-
- //local.randchoice randomint 5
- //local.randchoice ifequal 1 goto have_smoko
-
- goto idle_loop
-
- have_smoko:
- local.self state smoko
-
- end
-
- //***************************************************************
- //
- // Smoko stuff
- //
- //***************************************************************
-
- smoko:
-
- local.self clearstate
- local.self respondtoall
-
- local.self anim "smoke_start"
- //Need to set a time here so he doesn't smoke forever
- waitFor local.self
- local.self anim "smoke_into_hand"
-
- smoko_loop:
-
- local.self anim "smoke_idle"
- waitFor local.self
- local.randchoice randomint 3
- local.randchoice ifequal 0 goto smoko_twitch
-
- //if time exceeded goto smoko_end
- local.randchoice randomint 5
- local.randchoice ifequal 0 goto smoko_end
-
- goto smoko_loop
-
- smoko_twitch:
- local.self anim "smoke_twitch"
- waitFor local.self
- goto smoko_loop
-
- smoko_end:
- local.self anim "smoke_finish"
- waitFor local.self
- local.self state idle
- end
-
-